//
//  DDropLineHeaderView.swift
//  Drop
//
//  Created by hushaohua on 2018/2/24.
//  Copyright © 2018年 init. All rights reserved.
//

import UIKit

class DDropLineHeaderView: UITableViewHeaderFooterView {

    override init(reuseIdentifier: String?) {
        super.init(reuseIdentifier: reuseIdentifier);
        self.contentView.addSubview(self.timeLabel);
        self.addSubviewConstraints();
        self.backgroundView = UIView();
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    lazy var timeLabel:UILabel = {
        let label:UILabel = UILabel(frame: .zero);
        label.translatesAutoresizingMaskIntoConstraints = false;
        label.textColor = UIColor.gray;
        label.font = UIFont.systemFont(ofSize: 18, weight: .light);
        label.textAlignment = .left;
        return label;
    }();
    
    func addSubviewConstraints() -> Void{
        let views:[String : UIView] = ["time" : self.timeLabel];
        //"time" : self.beginDateLabel, "title" : self.titleLabel,
        var costraints = [NSLayoutConstraint]();
        costraints += NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[time]-0-|", options: [], metrics: nil, views: views);
        costraints += NSLayoutConstraint.constraints(withVisualFormat: "H:|-margin-[time]-|", options: .directionLeadingToTrailing, metrics: ["margin" : 8], views: views);
        self.contentView.addConstraints(costraints);
    }
    
    /*
    // Only override draw() if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    override func draw(_ rect: CGRect) {
        // Drawing code
    }
    */

}
